import { Commit } from "vuex";
import * as service from "@/service";
const cateList = {
  namespaced: true,
  state: {
    catelist: [],
    list: [],
  },
  actions: {
    async getCaleList(
      { commit }: { commit: Commit },
      { params }: { params: any }
    ) {
      const result = await service.fetchCateList(params);
      const action = {
        type: "GET_CATELIST",
        payload: result.data.content,
      };
      commit(action);
    },
    async getFood({ commit }: { commit: Commit }, { params }: { params: any }) {
      const result = await service.fetchFood(params);

      const action = {
        type: "GETFOOD",
        payload: result.data.goodsList,
      };
      commit(action);
    },
  },
  mutations: {
    GET_CATELIST(state: any, action: any) {
      state.catelist = action.payload;
    },
    GETFOOD(state: any, action: any) {
      state.list = action.payload;
    },
  },
};
export default cateList;
